#include "addlayout.h"
#include "ui_addlayout.h"
#include "cinemasystem.h"
#include <iostream>
#include "register.h"
#include "user.h"
#include "user_io.h"
#include "cinemasystem.h"
#include <string>
#include "administrator.h"



AddLayout::AddLayout(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::AddLayout)
{
    ui->setupUi(this);

}

AddLayout::~AddLayout()
{
    delete ui;
}

void AddLayout::on_confirm_clicked()
{
    //QString FilmName = ui->
    QString FilmName = ui->filmname->text();
    QTime FilmTime = ui->filmtime->time();//获取时间
    QDate FilmDate = ui->filmtime->date();//获取日期
    QString FilmPrise = ui->filmprice->text();
    QString Seeninghouse = ui->seeninghouse->text();//获取场次的字符串

    int __seen = Seeninghouse.toInt();

    CinemaSystem::Auditorium hall( 4, __seen);  //电影院新创建一个场次

    CinemaSystem cinemasystem("2023-10-17", "Sample Movie", 100.0);   //括号里的参数没用

    cinemasystem.halls= cinemasystem.readAuditoriumsFromFile("D:\\QT_projects\\Login\\2.txt");

    QString date = FilmTime.toString();
    QString date_2 = FilmDate.toString("yyyy-MM-dd");

    std::string __time = date.toStdString();
    std::string __date = date_2.toStdString();

    //std::cout<<__date+" "+__time<<std::endl;

    std::string full_date = __date+" "+__time;//日期+时间
    //std::string full_date = __date;//仅日期


    std::string name = FilmName.toStdString(); //QString转换为String
    double __filmprise = FilmPrise.toDouble();

    hall.movie[full_date] = {name, __filmprise};

    cinemasystem.addAuditorium(hall);  //把hall1push进movie的halls
    cinemasystem.saveAuditoriumsToFile("D:\\QT_projects\\Login\\2.txt");
    //cinemasystem.sale(1,1);
    Administrator *admist = new Administrator(this);
    admist->show();
    //this->destroy();


}
